package com.example.yslapplication.utils;


import ohos.distributedschedule.interwork.DeviceInfo;
import ohos.distributedschedule.interwork.DeviceManager;

import java.util.ArrayList;
import java.util.List;

public class DeviceUtil {
    public static List<String> getDevices() {
        List<DeviceInfo> deviceList = DeviceManager.getDeviceList(DeviceInfo.FLAG_GET_ONLINE_DEVICE);
        if (deviceList == null || deviceList.isEmpty())
            return null;

        List<String> deviceId = new ArrayList<>();
        deviceList.forEach(deviceInfo -> {
            deviceId.add(deviceInfo.getDeviceId());
        });
        return deviceId;
    }
}
